package com.ssy.lingxi.platform.template.service.controller.adorn;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.template.service.entity.adorn.ActivityPage;
import com.ssy.lingxi.platform.template.service.model.dto.common.CommonStatusDTO;
import com.ssy.lingxi.platform.template.service.model.dto.common.IdDTO;
import com.ssy.lingxi.platform.template.service.model.dto.web.SaveActivityPageDTO;
import com.ssy.lingxi.platform.template.service.model.qo.ActivityPageQO;
import com.ssy.lingxi.platform.template.service.service.web.ActivityPageWebService;
import com.ssy.lingxi.scheduler.api.model.ScheduleTaskCallbackVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @menu web - 活动页装修
 * @author fhj
 * @version 2.0.0
 * @date 2021/08/06
 */
@Api(tags = "web - 活动页装修")
@RestController
@RequestMapping("/template/web/activityPage")
public class ActivityPageController extends BaseController {

    @Resource
    private ActivityPageWebService activityPageWebService;

    @ApiOperation(value = "列表")
    @GetMapping("/page")
    public Wrapper<PageData<ActivityPage>> page(@Valid ActivityPageQO qo) {
        return activityPageWebService.page(qo, getSysUser());
    }

    @ApiOperation(value = "详情")
    @GetMapping(value = "/get")
    public Wrapper<ActivityPage> get(@Valid IdDTO dto) {
        return activityPageWebService.get(dto);
    }

    @ApiOperation(value = "新增")
    @PostMapping(value = "/add")
    public Wrapper<Long> add(@RequestBody @Validated({SaveActivityPageDTO.Add.class}) SaveActivityPageDTO dto) {
        return activityPageWebService.add(dto, getSysUser());
    }

    @ApiOperation(value = "修改")
    @PostMapping(value = "/update")
    public Wrapper<Void> update(@RequestBody @Validated({SaveActivityPageDTO.Update.class}) SaveActivityPageDTO dto) {
        return activityPageWebService.update(dto, getSysUser());
    }

    @ApiOperation(value = "删除")
    @PostMapping(value = "/delete")
    public Wrapper<Void> delete(@RequestBody @Valid IdDTO dto) {
        return activityPageWebService.delete(dto, getSysUser());
    }

    @ApiOperation(value = "上下线")
    @PostMapping(value = "/openOffLine")
    public Wrapper<Void> openOffLine(@RequestBody @Valid CommonStatusDTO dto) {
        return activityPageWebService.openOffLine(dto, getSysUser());
    }

    @ApiOperation(value = "装修")
    @PostMapping(value = "/adorn")
    public Wrapper<Void> adorn(@RequestBody @Validated({SaveActivityPageDTO.Adorn.class}) SaveActivityPageDTO dto) {
        return activityPageWebService.adorn(dto, getSysUser());
    }

    @ApiOperation(value = "定时服务回调 - 开始活动页")
    @PostMapping(value = "/start")
    public Wrapper<Void> start(@RequestBody ScheduleTaskCallbackVO dto) {
        return activityPageWebService.start(dto);
    }

    @ApiOperation(value = "定时服务回调 - 结束活动页")
    @PostMapping(value = "/end")
    public Wrapper<Void> end(@RequestBody ScheduleTaskCallbackVO dto) {
        return activityPageWebService.end(dto);
    }

    @ApiOperation(value = "列表（装修）")
    @GetMapping("/listAdorn")
    public Wrapper<PageData<ActivityPage>> listAdorn(@Valid ActivityPageQO qo) {
        return activityPageWebService.listAdorn(qo, getSysUser());
    }
}
